package tpju;


import java.util.ArrayList;

/**
* Write a description of class Magasin here.
* 
* @author (your name) 
* @version (a version number or a date)
*/
public class Magasin
{
   // instance variables
   private String  nom;
   private String  ville;
   private Responsable resp;
   private ArrayList <Rayon> ar;
   private static int nombre=0;
   
   // Constructor for objects of class Magasin
   public Magasin()
   {
       // initialise instance variables
       this.nom = null;
       this.ville=null;
       this.ar = new  ArrayList<Rayon>();
       Magasin.nombre++;
   }
 
   public Magasin(String n, String v)
   {
       // initialise instance variables
       this.nom = n;
       this.ville=v;
       this.ar = new  ArrayList<Rayon>();
   }
  
   public int getNbr(){
       return Magasin.nombre;
   }
   
   public String getNom(){
       return this.nom;
   }
   
   public void setNom(String s){
       this.nom=s;
   }
   
   public String getVille(){
       return this.ville;
   }
   
   public void setVille(String v){
       this.ville=v;
   }
   
   public Responsable getResponsable(){
       return this.resp;
   }
   
   public void addResponsable(Responsable resp){
       this.resp=resp;
   }
public void sampleMethod(){
       if(this.ville != null){
           if(Character.isLowerCase(this.ville.charAt(0))){
                this.ville=this.ville.toUpperCase();
           }
           else{
                this.ville=this.ville.toLowerCase();
           }
      }
      if(this.nom != null){
           if(Character.isLowerCase(this.nom.charAt(0))){
               this.nom=this.nom.toUpperCase();
           }
           else{
               this.nom=this.nom.toLowerCase();
           }
       }
   }
   
   public ArrayList<Rayon> getListe(){
       return this.ar;
   }
   
   public void supprimer(Rayon r){
       this.ar.remove(r);
       }
   
   public void ajouterRayon(Rayon r){
   if( !ar.contains(r) ){ 
                   if (r.getMagasin()!=null){
                           r.getMagasin().supprimer(r);
                   }
           }
   r.setMagasin(this);
   ar.add(r);
}
}